import React, { useState, useEffect } from 'react'
import style from './Warn.module.css'
import axios from 'axios'
const { warn, table } = style
const Warn = () => {
  //存储数据
  const [warnList, setwarnList] = useState([])

  useEffect(() => {
    axios.get('http://localhost:3004/warns').then(res => {
      setwarnList(res.data)
    })
  }, [])
  return (
    <div className={warn}>
      {warnList.map(item => (
        <div key={item.id} className={table}>
          <img src={item.imgUrl} alt="" />
          <div>
            <h2>{item.title}</h2>
            <p>{item.content}</p>
          </div>
        </div>
      ))}
    </div>
  )
}

export default Warn
